package com.qolome.knowledge.design.pattern.factory.simplefactory;

import java.util.Objects;

/**
 * @author Qolome
 * @version V1.0
 * @Description 课程工程
 * @date 2020年 02月27日 22:39:18
 */
public class CourseFactory {

    /*public ICourse create(String className){
        try {
            if(!StringUtils.isBlank(className)){
                return (ICourse)Class.forName(className).newInstance();
            }
        }catch (ClassNotFoundException | InstantiationException | IllegalAccessException e){
            e.printStackTrace();
        }

        return null;
    }*/

    public ICourse create(Class< ? extends ICourse> clazz){

        try {
            if (Objects.nonNull(clazz)) {
                return clazz.newInstance();
            }
        } catch (IllegalAccessException | InstantiationException e) {
            e.printStackTrace();
        }
        return null;
    }
}
